<?php

class Controller_Website extends Controller_Template {
    
    public function before() {
        
//        include_once 'fphp/fb.php';// FirePhp enable
//        $this->firephp = new FirePHP();
//        FB::setEnabled(true);//set false on the real server
    //======== enable error and exception handler ================//
//            $firephp->registerErrorHandler();
//            $firephp->registerExceptionHandler();
            
        parent::before();
        $this->db = Database::instance();
        $this->manager = Model::factory('manager');
        session_start();
        $this->template->title = $this->settings['title'];
        $this->template->description = $this->settings['description'];
        $this->template->keywords = $this->settings['keywords'];
        if(!empty ($_SESSION['cart']['shop']))
            {
                $result = 0;
                $itemsCount = count($_SESSION['cart']['shop']);
                foreach ($_SESSION['cart']['shop'] as $shopItem){
                    $result+=$shopItem['quantity'];
                }
                if($result > 99){
                    $result = '99+';
                }
                $this->template->itemsCount = $result;
            }
        if(!empty($_SESSION['identity'])){
            $userName = $this->manager->getUserName($_SESSION['identity']['id']);
            $this->template->userName = $userName;
        }
            
        
    }
}

?>
